﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.UserCommand;
using IntelligentAgriculture.WebAPI.Controllers;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.UserCommandHandler
{
	public class UserGetUserCommandHandler : IRequestHandler<UserGetUserCommand, Results<List<Userinfo>>>
	{
		private readonly IUserService _userService;
		private readonly ILogger<UserGetUserCommandHandler> _logger;
		public UserGetUserCommandHandler(IUserService userService, ILogger<UserGetUserCommandHandler> logger)
		{
			_userService = userService;
			_logger = logger;
		}
		public async Task<Results<List<Userinfo>>> Handle(UserGetUserCommand request, CancellationToken cancellationToken)
		{
			var userInfo = _userService.GetUsers();
			return  Results<List<Userinfo>>.DataResult(userInfo);
		}
	}
}
